/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAOs;

import dominio.Producto;
import java.util.List;
import org.hibernate.classic.Session;
import util.Myhibernateutil;
/**
 *
 * @author Angellem
 */
public class ProductosDAO {
  public void insertar(Producto prod) {   
  Session session = Myhibernateutil.getSessionFactory().getCurrentSession(); 
  session.beginTransaction(); 
  session.save(prod); 
  session.getTransaction().commit(); 
  Myhibernateutil.getSessionFactory().close();
} 
  


public List listarProductos() { 
  Session session = 
	Myhibernateutil.getSessionFactory().getCurrentSession();  
  session.beginTransaction(); 
  List result = session.createQuery("from Producto").list(); 
  session.getTransaction().commit(); 
  return result; 
}

}